﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _08.组合模式
{
    public class EventHandlerComposite : EventHandler
    {
        private readonly ICollection<EventHandler> _handlers = new HashSet<EventHandler>();

        public void Add(EventHandler handler)
        {
            this._handlers.Add(handler);
        }


        public override void Handle()
        {
            foreach (EventHandler handler in this._handlers)
            {
                handler.Handle();
            }
        }
    }
}
